import Vue from 'vue'
import App from './App'
import router from './router'
import store from './store/index'

import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import {
  getRoomID,
  getRandomString,
  dateFormat,
  getGlobalSetting,
  setGlobalSetting,
  removeGlobalSetting,
  handleWXShare
} from '@/utils/utils'
import VueClipboard from 'vue-clipboard2'
import * as api from '@/api/api'
import umconfig from './utils/umconfig'
import UmCore from './utils/umcore'

/** 资源文件 */
import '@/assets/css/common.css'
import um2 from 'umvideo2-client'

let umcore = UmCore(window)

/** UI组件 */
Vue.use(ElementUI)
Vue.use(VueClipboard)

Vue.prototype.api = api
Vue.prototype.$store = store
Vue.config.productionTip = false
Vue.prototype.$Creid = getRoomID
Vue.prototype.$GetRandomString = getRandomString
Vue.prototype.$dateFormat = dateFormat
Vue.prototype.setGlobalSetting = setGlobalSetting
Vue.prototype.getGlobalSetting = getGlobalSetting
Vue.prototype.removeGlobalSetting = removeGlobalSetting
Vue.prototype.$WXShare = handleWXShare
Vue.prototype.umvideo = um2
Vue.prototype.umconfig = umconfig
// 如果用户有在页面上指定了自定义配置，则使用用户配置来复盖默认配置
if (window && window.umconfig) {
  Vue.prototype.umconfig = Object.assign(Vue.prototype.umconfig, window.umconfig)
}
Vue.prototype.umcore = umcore

// 初始化内核
umcore.init({
  host: Vue.prototype.umconfig.host,
  wshost: Vue.prototype.umconfig.wshost
}).then(umcore => {
  console.log('umcore init ok')
})

new Vue({
  router,
  store,
  render: h => h(App)
}).$mount('#app')
